package model

import (
	"gorm.io/plugin/soft_delete"
	"time"
)

type BaseModel struct {
	ID        uint64                `gorm:"primarykey;comment:主键"`
	CreateAt  time.Time             `gorm:"column:create_time;autoCreateTime;comment:创建时间"`
	UpdateAt  time.Time             `gorm:"column:update_time;autoUpdateTime;comment:更新时间"`
	IsDeleted soft_delete.DeletedAt `gorm:"default:0;softDelete:flag,DeletedAtField:DeletedAt;default:0;comment:0未删除1删除"`
	// 忽略该字段，- 表示无读写，-:migration 表示无迁移权限，-:all 表示无读写迁移权限
	//Children any `gorm:"-" json:"children"`
}

type User struct {
	BaseModel
	Mobile   string     `gorm:"index:idx_mobile;unique;type:varchar(11);not null;comment:手机"`
	Password string     `gorm:"type:varchar(100);not null;comment:密码"`
	UserName string     `gorm:"type:varchar(20);comment:用户名"`
	NickName string     `gorm:"type:varchar(20);comment:昵称"`
	Birthday *time.Time `gorm:"type:datetime;comment:生日"`
	Gender   string     `gorm:"column:gender;default:male;type:varchar(6) comment 'female表示女, male表示男'"`
	Role     int        `gorm:"column:role;default:1;type:int comment '1表示普通用户, 2表示管理员'"`
}

func (u *User) TableName() string {
	return "ksd_users"
}
